package builder.AccountFormBuilderPackage;


import handler.assetFormHandlers.AFTextFieldKeyListener;

import javax.swing.JPasswordField;
import javax.swing.JTextField;

import builder.FormBuilder;
import builder.FormBuilderDecorator;

import checker.ValidLengthAndCharChecker;

import form.FormTextField;
import form.AccountForm.AccountForm;

public class AccountDecorator extends FormBuilderDecorator {

	
	public AccountDecorator(FormBuilder decoratee){
		super(decoratee);
	}
	
	
	public void setFormSettings() {
		// TODO Auto-generated method stub
		super.setFormSettings();
		
	}

	@Override
	public void buildComponents() {
		// TODO Auto-generated method stub
		super.buildComponents();
		
		AccountForm accountForm = (AccountForm) decoratee.getForm();
		buildRetypePasswordTF(accountForm);
		buildFNameTF(accountForm);
		buildLNameTF(accountForm);
	} 
	
	private void buildRetypePasswordTF(AccountForm accountForm) {
		JPasswordField retypepassword = new JPasswordField();
		retypepassword.setColumns(10);
		FormTextField retypePasswordTF = new FormTextField("Retype Password:", retypepassword, new ValidLengthAndCharChecker(ValidLengthAndCharChecker.ALPHANUMERIC,20));
		accountForm.getAccountInfoForm().setRetypePassword(retypePasswordTF);
		retypepassword.addKeyListener(new AFTextFieldKeyListener(retypePasswordTF));
		accountForm.add(retypePasswordTF);
	}

	private void buildFNameTF(AccountForm accountForm) {
		JTextField FName = new JTextField();
		FName.setColumns(10);
		FormTextField FNameTF = new FormTextField("First Name:", FName, new ValidLengthAndCharChecker(ValidLengthAndCharChecker.ALPHANUMERIC,20));
		accountForm.getAccountInfoForm().setFName(FNameTF);
		FName.addKeyListener(new AFTextFieldKeyListener(FNameTF));
		accountForm.add(FNameTF);
	}

	private void buildLNameTF(AccountForm accountForm) {
		JTextField LName = new JTextField();
		LName.setColumns(10);
		FormTextField LNameTF = new FormTextField("Last Name:", LName, new ValidLengthAndCharChecker(ValidLengthAndCharChecker.ALPHANUMERIC,20));
		accountForm.getAccountInfoForm().setLName(LNameTF);
		LName.addKeyListener(new AFTextFieldKeyListener(LNameTF));
		accountForm.add(LNameTF);
	}
	
}
